//
//  CustomAnnotationView.m
//  LanQiuQuan
//
//  Created by TonyGenius on 16/4/29.
//  Copyright © 2016年 Rip. All rights reserved.
//

#import "CustomAnnotationView.h"

@interface CustomAnnotationView()

#define kCalloutWidth       200.0
#define kCalloutHeight      70.0

@property (nonatomic, strong, readwrite) CustomCalloutView *calloutView;

@end

@implementation CustomAnnotationView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (void) setSelected:(BOOL)selected animated:(BOOL)animated
{
    if (self.selected == selected) {
        return;
    }
    if (selected) {
        if (self.calloutView == nil) {
            self.calloutView = [[CustomCalloutView alloc] initWithFrame:CGRectMake(0, 0, kCalloutWidth, kCalloutHeight)];
            self.calloutView.center = CGPointMake(CGRectGetWidth(self.bounds)/2.f + self.calloutOffset.x, CGRectGetHeight(self.bounds)/2.f + self.calloutOffset.y);
        }
        self.calloutView.image = [UIImage imageNamed:@"8.jpg"];
        self.calloutView.title = self.annotation.title;
        self.calloutView.subtitle = self.annotation.subtitle;
//        self.calloutView.backGroundImage = [UIImage imageNamed:@"mapPositionBG"];
        
        [self addSubview:self.calloutView];
    }
    else
    {
        [self.calloutView removeFromSuperview];
    }
    
    [super setSelected:selected animated:YES];
}

@end
